<?php
namespace app\index\controller;

use think\Controller;

class Pay extends Base
{
    public function index()
    {
        if (!$this->getLoginUser()) {
            $this->error('请登录', url('user/login'));
        }
        $orderId = input('get.id', 0, 'intval');
        if (empty($orderId)) {
            $this->error('请求不合法');
        }
        $order = model('Order')->get($orderId);
        if (empty($order) || $order->status != 1 || $order->pay_status != 0) {
            $this->error('无法进行该操作');
        }
        // 严格判断当前用户是否是登陆用户
        if ($order->username != $this->getLoginUser()->username) {
            $this->error('无权限操作');
        }
        $deal = model('Deal')->get($order->deal_id);

        return $this->fetch('', [
            'deal' => $deal,
            'order' => $order,
        ]);
    }
}
